/*
 * @Author: 飞越疯人院 353362604@qq.com
 * @Date: 2022-09-23 15:40:50
 * @LastEditors: 飞越疯人院 353362604@qq.com
 * @LastEditTime: 2022-12-18 11:19:09
 * @FilePath: \adminstration\src\Common\Modal\TwoModalList\FileManagement.jsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { API_LIST } from '../../Api/Api'
import { TwoAddBtn, ThrDeleteBtn, SeeEnclosure, OpenThrBtn } from '../options'
export const FileManagement = async ({ upDataEvent, data }) => {
    let dataList = {
        type: '添加附件',
        hideInSearch: true,
        pageSize: 10,
        params: {},
        classification: 'TableModal',
        get: API_LIST([data.uuid])['getInfoManageDetail'],
        additional: { key: 'InfoManageUuid', value: 'uuid' },
        options: [
            <TwoAddBtn
                upDataEvent={upDataEvent}
                title="添加文件附件"
                ThrKey="ThrModal"
                value="FileManagement"
                data={data}
            />,
        ],
        columns: [
            {
                dataIndex: 'infoManageUuid',
                title: '文件uuid',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                dataIndex: 'tableName',
                title: '说明',
                valueType: 'input',
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '创建时间',
                dataIndex: 'createTime',
                valueType: 'input',
                hideInTable: true,
                hideInAdded: true,
                hideInModify: true,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { fileUrl, coverUrl } = record
                    return [
                        fileUrl && (
                            <SeeEnclosure
                                key="see"
                                title="查看附件"
                                data={{
                                    className: 'Admin',
                                    url: fileUrl,
                                }}
                            />
                        ),
                        coverUrl && (
                            <SeeEnclosure
                                key="seeCover"
                                title="查看封面"
                                data={{
                                    className: 'Admin',
                                    url: coverUrl,
                                }}
                            />
                        ),
                        <ThrDeleteBtn
                            key="delete"
                            record={record.uuid}
                            upDataEvent={upDataEvent}
                            data={{ key: 'delete', url: 'delInfoManageDetail', title: '删除样品附件' }}
                        />,
                    ]
                },
            },
        ],
    }
    return dataList
}
